home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
usr (gcc 1.37 libs)
/
mac
/
gcc-1.37-libc.s
< prev
next >
Wrap
Text File
|
1993-12-14
|
3KB
|
186 lines
.text
.even
.globl ENTRY_SYMBOL
.globl __main
ENTRY_SYMBOL:
__main:
; .word $A9FF ; debugger
jmp _crt_getargs
.even
.comm _qd,206
.even
; subroutines needed in certain awkward SANE situations
.lcomm _TMPINT,4
.globl _XTOU
_XTOU:
movel sp@+,a0
pea _TMPINT
movew #$3010,sp@-
.word $a9eb
movel _TMPINT,d0
jmp a0@
.globl _XTOI
_XTOI:
movel sp@+,a0
pea _TMPINT
movew #$2810,sp@-
.word $a9eb
movel _TMPINT,d0
jmp a0@
;
; memcpy used to initialise large data at start of a subroutine
;
.globl _memcpy
_memcpy:
link a6,#0
movel a6@(8),a1 ; dest
movel a6@(12),a0 ; src
movel a6@(16),d0 ; total bytes
beq endcpy
nxtcpy:
moveb a0@+,a1@+
dbne d0,nxtcpy
endcpy:
unlk a6
rts
.byte $86
.ascii "memcpy"
.byte 0
.even
.word 0 ; dummy size of literals
.even
;
; the actual multiply D0 = D0*D1
;
.globl ULMULT
ULMULT:
movel d0,d2
movel d1,d3
swap d2
muluw d3,d2
movel d0,d4
movel d1,d5
swap d5
muluw d5,d4
addw d4,d2
swap d2
clrw d2
muluw d1,d0
addl d2,d0
rts
.byte $86
.ascii "ULMULT"
.byte 0
.even
.word 0 ; dummy size of literals
.even
;
; D0 = D0 / D1 (signed)
; D1 = D0 % D1 (signed)
;
.globl SLDIVT
SLDIVT:
tstl d0
jpl signed_div1
tstl d1
jpl signed_div2
negl d0
negl d1
jbsr unsigned_div
negl d1
bra signed_div3
signed_div2:
negl d0
jbsr unsigned_div
negl d0
negl d1
bra signed_div3
signed_div1:
tstl d1
jpl unsigned_div
negl d1
jbsr unsigned_div
negl d0
signed_div3:
rts
.byte $86
.ascii "SLDIVT"
.byte 0
.even
.word 0 ; dummy size of literals
.even
;
; D0 = D0 / D1 (unsigned)
; D1 = D0 % D1 (unsigned)
;
.globl ULDIVT
ULDIVT:
unsigned_div:
movel #0x0000ffff,d7
cmpl d0,d1
jls unsigned_div1
movel d0,d1
moveq #0x00,d0
bra unsigned_div99
unsigned_div1:
cmpl d7,d0
jhi unsigned_div2
divuw d1,d0
swap d0
movew d0,d1
clrw d0
swap d0
bra unsigned_div99
unsigned_div2:
cmpl d7,d1
jhi unsigned_div3
movel d0,d7
clrw d0
swap d0
divuw d1,d0
swap d0
swap d7
movew d0,d7
swap d7
divuw d1,d7
movew d7,d0
swap d7
movew d7,d1
bra unsigned_div99
unsigned_div6:
subqw #0x1,d0
bra unsigned_div5
unsigned_div3:
movel d0,d2
movel d1,d3
unsigned_div4:
lsrl #0x1,d0
lsrl #0x1,d1
cmpl d7,d1
jhi unsigned_div4
divuw d1,d0
andl d7,d0
unsigned_div5:
movew d3,d1
muluw d0,d1
movel d3,d7
swap d7
muluw d0,d7
swap d7
addl d7,d1
jcs unsigned_div6
subl d2,d1
jhi unsigned_div6
negl d1
unsigned_div99:
rts
.byte $86
.ascii "ULDIVT"
.byte 0
.even
.word 0 ; dummy size of literals
.even